<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Upload extends CI_Controller {

     function __construct() {

        parent::__construct();
       // $this->load->helper('url');
        $this->load->library('parser');
        //$this->load->library('multy_upload');
        $this->load->helper(array('form', 'url'));
     }
     
    function Upload()
    {
        parent::Controller();
        $this->load->helper(array('form', 'url'));
    }
    
    function index()
    {    
        $this->load->view('upload_form');
    }

        function doupload(){

    $uploadFile = uri_assoc('fld',2);
    $config['upload_path'] = './uploads/';
    $config['allowed_types'] = 'gif|jpg|png';
    $this->load->library('upload', $config);

    if ( ! $this->upload->do_upload($uploadFile))
    {
    $error = array('error' => $this->upload->display_errors());

    $this->load->view('upload_form', $error);
    }
    else
    {
    $data = array('upload_data' => $this->upload->data());

    $this->load->view('upload_success');
    }

    }

    
    function do_upload()
    {
        
        $uploaddir = './uploads/';
       // $uploaddir = 'C:\\wamp\www\\vntsolution\uploads\\';
        $file = $uploaddir . basename($_FILES['uploadfile']['name']);

        if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
          echo "success";
        }
        else {
                echo "error";
        }
    }    
}
?>